import pymssql
class DataSql:
    def readdata(self,sql):
        conn = pymssql.connect(
        host='192.168.0.251',
        port=3833,
        user='ddgame',
        password='dd373_jsbdb',
        charset='utf8',
        database='DD373_ZuHao'
        )
        cursor = conn.cursor()  # 执行结束后，返回的结果默认以字典显示cursor=pymssql.cursors.DictCursor
        cursor.execute(sql)
        row = cursor.fetchmany()[0]
        conn.commit()
        cursor.close()
        conn.close()
        return row
if __name__=="__main__":
    c=DataSql()
    b=c.readdata("select * from DD373_ZuHao.dbo.ZuShop where UserId in (select UserId from DD373_Login.dbo.Users where UserName='wap19') and State=8")
    print(b[0])
